
package interfaz;
import dominio.*;
import integracion.*;
import java.awt.Color;
import java.awt.Component;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Time;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
/**
 *
 * @author Diana Uribe
 */
public class generarFactura extends javax.swing.JFrame {

    ControlProveedor controlProveedor;
    ControlFactura controlFactura;
    ControlCuota controlCuota;
    ControlOrdenCompra controlOrdenCompra;
    ControlPago controlPago;
    ControlRecibo controlRecibo;
    ControlEvento controlEvento;
    ControlCotizacion controlCotizacion;
    ControlEmpleado controlEmpleado;
    ControlClienteCompania controlClienteCompania;
    ControlClienteParticular controlClienteParticular;
    ControlUso controlUso;
    ControlInsumoInventario controlInsumoInventario;
    ControlInsumo controlInsumo;
    NuevaCotizacion NuevaCotizacion;

    /** Creates new form generarFactura */
    public generarFactura(Integer idEvento) {
        initComponents();
        this.asignarLabelEventosSegundaCuota(idEvento);
        this.asignarLabelFechaCotizacion(idEvento);
        this.cargarTablaFactura(idEvento);
        this.cargarTablaEmpleadosContratados(idEvento);
        this.calcularSubTotal();
        this.calcularIva();
        this.calcularDeposito();
        this.calcularTotal();
        this.setLocation(210, 10);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel15 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        fechaCotizacionLabel = new javax.swing.JLabel();
        jPanel16 = new javax.swing.JPanel();
        jLabel56 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        fechaLabel = new javax.swing.JLabel();
        ejecutivoEncargadoLabel = new javax.swing.JLabel();
        jLabel34 = new javax.swing.JLabel();
        horaInicio = new javax.swing.JLabel();
        jLabel36 = new javax.swing.JLabel();
        horaFin = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        duracionEvento = new javax.swing.JLabel();
        jLabel122 = new javax.swing.JLabel();
        jLabel66 = new javax.swing.JLabel();
        descripcionEventoFactura = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        lugarEventoFactura = new javax.swing.JLabel();
        jPanel17 = new javax.swing.JPanel();
        jLabel57 = new javax.swing.JLabel();
        rifLabel = new javax.swing.JLabel();
        jLabel58 = new javax.swing.JLabel();
        nombreClienteLabel = new javax.swing.JLabel();
        jLabel59 = new javax.swing.JLabel();
        ciLabel = new javax.swing.JLabel();
        jLabel63 = new javax.swing.JLabel();
        direccionCliente = new javax.swing.JLabel();
        jLabel65 = new javax.swing.JLabel();
        telefonoCliente = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        pagoTotalLabel = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        nroFacturaLabel = new javax.swing.JLabel();
        jLabel60 = new javax.swing.JLabel();
        subtotal1 = new javax.swing.JLabel();
        iva1 = new javax.swing.JLabel();
        jLabel61 = new javax.swing.JLabel();
        jLabel62 = new javax.swing.JLabel();
        deposito1 = new javax.swing.JLabel();
        jLabel64 = new javax.swing.JLabel();
        jLabel119 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tablaFactura = new javax.swing.JTable();
        jPanel11 = new javax.swing.JPanel();
        jScrollPane8 = new javax.swing.JScrollPane();
        tablaEmpleadosContratados = new javax.swing.JTable();
        jMenuBar1 = new javax.swing.JMenuBar();
        archivo = new javax.swing.JMenu();
        nuevaCotizacion = new javax.swing.JMenuItem();
        informacionSistema = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        exit = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        acercaDe = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Factura del Evento");

        jPanel15.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        jPanel15.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 12));
        jPanel15.setPreferredSize(new java.awt.Dimension(810, 283));

        jLabel1.setFont(new java.awt.Font("Calibri", 0, 12));
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/logoPeq1.PNG"))); // NOI18N

        jLabel3.setFont(new java.awt.Font("Script MT Bold", 2, 18));
        jLabel3.setText("Festejos y Decoraciones MDJ");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel5.setText("Fecha:");

        fechaCotizacionLabel.setText("----/--/--");

        jPanel16.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Información del Evento", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N

        jLabel56.setText("Fecha del Evento:");

        jLabel4.setText("Ejecutivo Encargado:");

        fechaLabel.setText("----/--/--");

        ejecutivoEncargadoLabel.setText("Ejecutivo Encargado");

        jLabel34.setText("Hora del Evento:");

        horaInicio.setText("00:00");

        jLabel36.setText("a");

        horaFin.setText("00:00");

        jLabel20.setText("Duración:");

        duracionEvento.setText("0");

        jLabel122.setText("hora(s)");

        jLabel66.setText("Descripción del Evento:");

        descripcionEventoFactura.setText("descripción");

        jLabel2.setText("Lugar del Evento:");

        lugarEventoFactura.setText("lugar evento");

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel16Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ejecutivoEncargadoLabel))
                    .addGroup(jPanel16Layout.createSequentialGroup()
                        .addComponent(jLabel66)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(descripcionEventoFactura))
                    .addGroup(jPanel16Layout.createSequentialGroup()
                        .addComponent(jLabel56)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(fechaLabel))
                    .addGroup(jPanel16Layout.createSequentialGroup()
                        .addComponent(jLabel34)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(horaInicio)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel36)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(horaFin))
                    .addGroup(jPanel16Layout.createSequentialGroup()
                        .addComponent(jLabel20)
                        .addGap(41, 41, 41)
                        .addComponent(duracionEvento)
                        .addGap(28, 28, 28)
                        .addComponent(jLabel122))
                    .addGroup(jPanel16Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lugarEventoFactura)))
                .addContainerGap(132, Short.MAX_VALUE))
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel16Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel66)
                    .addComponent(descripcionEventoFactura))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel56)
                    .addComponent(fechaLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel34)
                    .addComponent(jLabel36)
                    .addComponent(horaFin)
                    .addComponent(horaInicio))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(duracionEvento)
                    .addComponent(jLabel122))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(lugarEventoFactura))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(ejecutivoEncargadoLabel))
                .addContainerGap())
        );

        jPanel17.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Información del Cliente", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N

        jLabel57.setText("RIF:");

        rifLabel.setText("--");

        jLabel58.setText("Nombre del Cliente:");

        nombreClienteLabel.setText("Nombre Cliente");

        jLabel59.setText("C.I.:");

        ciLabel.setText("--");

        jLabel63.setText("Dirección:");

        direccionCliente.setText("Dirección");

        jLabel65.setText("Teléfono:");

        telefonoCliente.setText("teléfono");

        javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17);
        jPanel17.setLayout(jPanel17Layout);
        jPanel17Layout.setHorizontalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addComponent(jLabel58)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(nombreClienteLabel))
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addComponent(jLabel57)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rifLabel))
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addComponent(jLabel59)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ciLabel))
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addComponent(jLabel63)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(direccionCliente))
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addComponent(jLabel65)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(telefonoCliente)))
                .addContainerGap(214, Short.MAX_VALUE))
        );
        jPanel17Layout.setVerticalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nombreClienteLabel)
                    .addComponent(jLabel58))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel59)
                    .addComponent(ciLabel))
                .addGap(14, 14, 14)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(rifLabel)
                    .addComponent(jLabel57))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel63)
                    .addComponent(direccionCliente))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel65)
                    .addComponent(telefonoCliente))
                .addContainerGap())
        );

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel12.setText("TOTAL Bs.F.:");

        pagoTotalLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
        pagoTotalLabel.setForeground(new java.awt.Color(0, 153, 0));
        pagoTotalLabel.setText("0.0");

        jLabel14.setText("Nro.");

        nroFacturaLabel.setForeground(new java.awt.Color(204, 0, 0));
        nroFacturaLabel.setText("000000");

        jLabel60.setFont(new java.awt.Font("Tahoma", 0, 10));
        jLabel60.setText("Sub - TOTAL BsF.");

        subtotal1.setFont(new java.awt.Font("Tahoma", 0, 10));
        subtotal1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        subtotal1.setText("0.0");
        subtotal1.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);

        iva1.setFont(new java.awt.Font("Tahoma", 0, 10));
        iva1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        iva1.setText("0.0");

        jLabel61.setFont(new java.awt.Font("Tahoma", 0, 10));
        jLabel61.setText("IVA 9% BsF.");

        jLabel62.setFont(new java.awt.Font("Tahoma", 0, 10));
        jLabel62.setText("5% Deposito por Averias BsF.");

        deposito1.setFont(new java.awt.Font("Tahoma", 0, 10));
        deposito1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        deposito1.setText("0.0");

        jLabel64.setText("00 -");

        jLabel119.setFont(new java.awt.Font("Script MT Bold", 2, 18));
        jLabel119.setText("Facturas de");

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Insumos"));

        tablaFactura.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Cantidad", "Concepto", "Costo Unitario", "Monto"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaFactura.getTableHeader().setReorderingAllowed(false);
        jScrollPane3.setViewportView(tablaFactura);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder("Contratados"));

        tablaEmpleadosContratados.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Cedula", "Nombre", "Cargo", "CostoHora"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaEmpleadosContratados.getTableHeader().setReorderingAllowed(false);
        jScrollPane8.setViewportView(tablaEmpleadosContratados);

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 328, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel119, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)
                            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE))
                        .addGap(377, 377, 377)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel15Layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addGap(34, 34, 34)
                                .addComponent(fechaCotizacionLabel))
                            .addGroup(jPanel15Layout.createSequentialGroup()
                                .addComponent(jLabel14)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel64)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(nroFacturaLabel))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel15Layout.createSequentialGroup()
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel12)
                            .addComponent(jLabel60)
                            .addComponent(jLabel61)
                            .addComponent(jLabel62))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(deposito1, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(iva1, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(subtotal1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(pagoTotalLabel, javax.swing.GroupLayout.Alignment.TRAILING)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel15Layout.createSequentialGroup()
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel15Layout.createSequentialGroup()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(jLabel64)
                            .addComponent(nroFacturaLabel))
                        .addGap(41, 41, 41)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(fechaCotizacionLabel)))
                    .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel1)
                        .addGroup(jPanel15Layout.createSequentialGroup()
                            .addComponent(jLabel119)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jLabel3))))
                .addGap(15, 15, 15)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(5, 5, 5)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addComponent(subtotal1)
                        .addGap(5, 5, 5)
                        .addComponent(iva1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(deposito1)
                        .addGap(18, 18, 18)
                        .addComponent(pagoTotalLabel))
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addComponent(jLabel60)
                        .addGap(5, 5, 5)
                        .addComponent(jLabel61)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel62)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel12)))
                .addContainerGap())
        );

        archivo.setText("Archivo");

        nuevaCotizacion.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
        nuevaCotizacion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/add.png"))); // NOI18N
        nuevaCotizacion.setText("Nueva Cotizacion...");
        nuevaCotizacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nuevaCotizacionActionPerformed(evt);
            }
        });
        archivo.add(nuevaCotizacion);

        informacionSistema.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        informacionSistema.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/database.png"))); // NOI18N
        informacionSistema.setText("Informacion del Sistema...");
        informacionSistema.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                informacionSistemaActionPerformed(evt);
            }
        });
        archivo.add(informacionSistema);

        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/money.png"))); // NOI18N
        jMenuItem2.setText("Cancelacion de Eventos");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        archivo.add(jMenuItem2);
        archivo.add(jSeparator1);

        exit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
        exit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/exit.png"))); // NOI18N
        exit.setText("Salir");
        exit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitActionPerformed(evt);
            }
        });
        archivo.add(exit);

        jMenuBar1.add(archivo);

        jMenu1.setText("Ayuda");

        acercaDe.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        acercaDe.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/info.png"))); // NOI18N
        acercaDe.setText("Acerca de MDJ");
        acercaDe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                acercaDeActionPerformed(evt);
            }
        });
        jMenu1.add(acercaDe);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, 819, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel15, javax.swing.GroupLayout.DEFAULT_SIZE, 574, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void nuevaCotizacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nuevaCotizacionActionPerformed
        NuevaCotizacion cot;
        try {
            cot = new NuevaCotizacion();
            cot.setVisible(true);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema2.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_nuevaCotizacionActionPerformed

    private void informacionSistemaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_informacionSistemaActionPerformed
        InformacionSistema2 info = new InformacionSistema2();
        info.setVisible(true);
}//GEN-LAST:event_informacionSistemaActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        cancelacionEvento ce = new cancelacionEvento();
        ce.setVisible(true);
}//GEN-LAST:event_jMenuItem2ActionPerformed

    private void exitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitActionPerformed
        int resultado = JOptionPane.showConfirmDialog(null, "Esta seguro que desea realizar esta operacion?", "ATENCION", JOptionPane.OK_CANCEL_OPTION);
        if (resultado == 0) {
            System.exit(0);
        }
}//GEN-LAST:event_exitActionPerformed

    private void acercaDeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acercaDeActionPerformed
        About ab = new About();
        ab.setVisible(true);
}//GEN-LAST:event_acercaDeActionPerformed

    private void cargarTablaEmpleadosContratados(Integer id) {
        DefaultTableModel dm = new DefaultTableModel();

        dm.addColumn("Cedula");
        dm.addColumn("Nombre");
        dm.addColumn("Cargo");
        dm.addColumn("CostoHora");
        try {
            controlEvento = new ControlEvento();
            List<Evento> eventos = controlEvento.consultarEventosSegundaCuota();

            controlUso = new ControlUso();
            List<Uso> usos = controlUso.consultarUsoEmpleado();

            controlEmpleado = new ControlEmpleado();
            List<Empleado> empleados = controlEmpleado.consultarEmpleadoEvento();

            
                for (int i = 0; i < eventos.size(); i++) {
                    if (eventos.get(i).getIdEvento().equals(id)) {
                        for (int j = 0; j < usos.size(); j++) {
                            if(id.equals(usos.get(j).getEVENTO_idEVENTO())){
                                for (int k = 0; k < empleados.size(); k++) {
                                    if(usos.get(j).getEMPLEADO_cedula().equals(empleados.get(k).getCedula())){
                                        Vector even = new Vector();

                                        even.addElement(usos.get(j).getEMPLEADO_cedula());
                                        even.addElement(empleados.get(k).getNombre()+"  "+empleados.get(k).getApellido());
                                        even.addElement(empleados.get(k).getCargoContratado());
                                        even.addElement(empleados.get(k).getCostoHoraContratado());

                                        dm.addRow(even);
                                    }

                                }


                            }

                        }

                    }
                }
                tablaEmpleadosContratados.setModel(dm);
                tablaEmpleadosContratados.setEnabled(false);
            
        } catch (IOException ex) {
            Logger.getLogger(InformacionSistema2.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema2.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void cargarTablaFactura(Integer id) {
        DefaultTableModel dm = new DefaultTableModel();

        dm.addColumn("Cantidad");
        dm.addColumn("Concepto");
        dm.addColumn("Costo Unitario");
        dm.addColumn("Monto");
        try {
            controlEvento = new ControlEvento();
            List<Evento> eventos = controlEvento.consultarEventosSegundaCuota();

            controlCuota = new ControlCuota();
            List<Cuota> cuotas = controlCuota.consultarCuotaFactura();

            controlPago = new ControlPago();
            List<Pago> pagos = controlPago.consultarPagoFactura();

            controlCotizacion = new ControlCotizacion();
            List<Cotizacion> cotizaciones = controlCotizacion.consultarCotizacionesFactura();

            controlUso = new ControlUso();
            List<Uso> usos = controlUso.consultarUsoFactura();

            controlInsumo = new ControlInsumo();
            List<Insumo> insumos = controlInsumo.consultarInsumoFactura();

            controlInsumoInventario = new ControlInsumoInventario();
            List<InsumoInventario> insumoInventario = controlInsumoInventario.consultarInsumoInventarioFactura();

                for (int i = 0; i < eventos.size(); i++) {
                    if (eventos.get(i).getIdEvento().equals(id)) {
                        for (int j = 0; j < cotizaciones.size(); j++) {
                            if (eventos.get(i).getIdEvento().equals(cotizaciones.get(j).getEventoIdEvento())) {
                                for (int u = 0; u < usos.size(); u++) {
                                    if (eventos.get(i).getIdEvento().equals(usos.get(u).getEVENTO_idEVENTO())) {
                                        for (int s = 0; s < insumos.size(); s++) {
                                            if (usos.get(u).getINSUMO_idINSUMO().equals(insumos.get(s).getIdINSUMO())) {
                                                for (int r = 0; r < insumoInventario.size(); r++) {
                                                    if (insumos.get(s).getIdINSUMO().equals(insumoInventario.get(r).getINSUMO_idINSUMO())) {
                                                        for (int p = 0; p < pagos.size(); p++) {
                                                            if (pagos.get(p).getCotizacionEventoIdEvento().equals(usos.get(u).getEVENTO_idEVENTO())) {
                                                                for (int a = 0; a < cuotas.size(); a++) {
                                                                    if (pagos.get(p).getIdPago().equals(cuotas.get(a).getPagoIdpago())) {
                                                                        if (cuotas.get(a).getCuota().equals("2")) {
                                                                            Vector even = new Vector();
                                                                            even.addElement(usos.get(u).getCantidad());
                                                                            even.addElement(insumos.get(s).getConcepto());
                                                                            even.addElement(insumoInventario.get(r).getCostoUnitario());
                                                                            even.addElement(usos.get(u).getCantidad() * insumoInventario.get(r).getCostoUnitario());

                                                                            dm.addRow(even);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                tablaFactura.setModel(dm);
                tablaFactura.setEnabled(false);
            
        } catch (IOException ex) {
            Logger.getLogger(InformacionSistema2.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema2.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    private void asignarLabelFechaCotizacion(Integer id) {

        try {
            controlEvento = new ControlEvento();
            List<Evento> eventos = controlEvento.consultarEventosSegundaCuota();

            controlCotizacion = new ControlCotizacion();
            List<Cotizacion> cotizaciones = controlCotizacion.consultarFechaCotizaciones();

            controlClienteCompania = new ControlClienteCompania();
            List<ClienteCompania> companias = controlClienteCompania.consultarClienteCompaniaSegundaCuota();

            controlClienteParticular = new ControlClienteParticular();
            List<ClienteParticular> particular = controlClienteParticular.consultarClienteParticularSegundaCuota();

                for (int i = 0; i < eventos.size(); i++) {
                    if (eventos.get(i).getIdEvento().equals(id)) {
                        for (int j = 0; j < cotizaciones.size(); j++) {
                            if (eventos.get(i).getIdEvento().equals(cotizaciones.get(j).getEventoIdEvento())) {
                                fechaCotizacionLabel.setText(eventos.get(i).getFecha().toString());

                                Time horaI = Time.valueOf(eventos.get(i).getHoraInicio().toString());
                                Time horaF = Time.valueOf(eventos.get(i).getHoraFin().toString());
                                long diferencia = horaF.getTime() - horaI.getTime();
                                long horasD = diferencia / (1000 * 60 * 60);
                                duracionEvento.setText(String.valueOf(horasD));

                                if (cotizaciones.get(j).getClienteCompaniaRif().equals("")) {
                                    rifLabel.setText("--");
                                } else {
                                    rifLabel.setText(cotizaciones.get(j).getClienteCompaniaRif());

                                    for (int z = 0; z < companias.size(); z++) {
                                        if (cotizaciones.get(j).getClienteCompaniaRif().equals(companias.get(z).getRif())) {
                                            nombreClienteLabel.setText(companias.get(z).getNombre());
                                            direccionCliente.setText(companias.get(z).getDireccion());
                                            telefonoCliente.setText(companias.get(z).getTelefono());
                                        }
                                    }
                                }
                                if (cotizaciones.get(j).getClienteParticularCedula().equals(0)) {
                                    ciLabel.setText("--");
                                } else {
                                    ciLabel.setText(cotizaciones.get(j).getClienteParticularCedula().toString());

                                    for (int z = 0; z < particular.size(); z++) {
                                        if (cotizaciones.get(j).getClienteParticularCedula().equals(particular.get(z).getCedula())) {
                                            nombreClienteLabel.setText(particular.get(z).getNombre() + " " + particular.get(z).getApellido());
                                            direccionCliente.setText(particular.get(z).getDireccion());
                                            telefonoCliente.setText(particular.get(z).getTelefono());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            

        } catch (IOException ex) {
            Logger.getLogger(InformacionSistema2.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema2.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    private void asignarLabelEventosSegundaCuota(Integer id) {
        try {
            controlEvento = new ControlEvento();
            List<Evento> eventos = controlEvento.consultarEventosSegundaCuota();

            controlEmpleado = new ControlEmpleado();
            List<Empleado> ejecutivos = controlEmpleado.consultarEjecutivosEncargado();
            controlEvento = new ControlEvento();
            List<Evento> eventoEjecutivo = controlEvento.consultarEventosEjecutivo();
            
                for (int i = 0; i < eventos.size(); i++) {
                    if (eventos.get(i).getIdEvento().equals(id)) {

                        nroFacturaLabel.setText("00103" + eventos.get(i).getIdEvento().toString());
                        descripcionEventoFactura.setText(eventos.get(i).getDescripcion());
                        fechaLabel.setText(eventos.get(i).getFecha().toString());
                        horaInicio.setText(eventos.get(i).getHoraInicio().toString());
                        horaFin.setText(eventos.get(i).getHoraFin().toString());
                        lugarEventoFactura.setText(eventos.get(i).getLugar());
                    }
                }
                for (int z = 0; z < eventoEjecutivo.size(); z++) {
                    if (eventoEjecutivo.get(z).getIdEvento().equals(id)) {
                        for (int j = 0; j < ejecutivos.size(); j++) {
                            if (eventoEjecutivo.get(z).getEjecutivoCedula().equals(ejecutivos.get(j).getCedula())) {
                                ejecutivoEncargadoLabel.setText(ejecutivos.get(j).getNombre() + " " + ejecutivos.get(j).getApellido());
                            }
                        }

                    }
                }
            
        } catch (IOException ex) {
            Logger.getLogger(InformacionSistema2.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(InformacionSistema2.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void calcularSubTotal() {
        double acum = 0.0;
        for (int i = 0; i < tablaFactura.getRowCount(); i++) {
            acum = acum + Double.valueOf(tablaFactura.getValueAt(i, 3).toString());
            subtotal1.setText(Double.toString(acum));
        }
    }

    private void calcularIva() {
        double monto = Double.valueOf(subtotal1.getText());
        double ivaValor = monto * 0.09;
        double resultado = this.redondear(ivaValor, 2);
        iva1.setText(Double.toString(resultado));
    }

    private void calcularDeposito() {
        double monto = Double.valueOf(subtotal1.getText());
        double depValor = monto * 0.05;
        double resultado = this.redondear(depValor, 2);
        deposito1.setText(Double.toString(resultado));
    }

     private void calcularTotal() {
        double Subtotal = Double.valueOf(subtotal1.getText().toString());
        double Iva = Double.valueOf(iva1.getText().toString());
        double Deposito = Double.valueOf(deposito1.getText().toString());
        double resultado = this.redondear(Subtotal + Iva + Deposito, 2);
        pagoTotalLabel.setText(Double.toString(resultado));
    }

    private double redondear(double numero, int decimales) {
        return Math.round(numero * Math.pow(10, decimales)) / Math.pow(10, decimales);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem acercaDe;
    private javax.swing.JMenu archivo;
    private javax.swing.JLabel ciLabel;
    private javax.swing.JLabel deposito1;
    private javax.swing.JLabel descripcionEventoFactura;
    private javax.swing.JLabel direccionCliente;
    private javax.swing.JLabel duracionEvento;
    private javax.swing.JLabel ejecutivoEncargadoLabel;
    private javax.swing.JMenuItem exit;
    private javax.swing.JLabel fechaCotizacionLabel;
    private javax.swing.JLabel fechaLabel;
    private javax.swing.JLabel horaFin;
    private javax.swing.JLabel horaInicio;
    private javax.swing.JMenuItem informacionSistema;
    private javax.swing.JLabel iva1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel119;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel122;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel56;
    private javax.swing.JLabel jLabel57;
    private javax.swing.JLabel jLabel58;
    private javax.swing.JLabel jLabel59;
    private javax.swing.JLabel jLabel60;
    private javax.swing.JLabel jLabel61;
    private javax.swing.JLabel jLabel62;
    private javax.swing.JLabel jLabel63;
    private javax.swing.JLabel jLabel64;
    private javax.swing.JLabel jLabel65;
    private javax.swing.JLabel jLabel66;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel lugarEventoFactura;
    private javax.swing.JLabel nombreClienteLabel;
    private javax.swing.JLabel nroFacturaLabel;
    private javax.swing.JMenuItem nuevaCotizacion;
    private javax.swing.JLabel pagoTotalLabel;
    private javax.swing.JLabel rifLabel;
    private javax.swing.JLabel subtotal1;
    private javax.swing.JTable tablaEmpleadosContratados;
    private javax.swing.JTable tablaFactura;
    private javax.swing.JLabel telefonoCliente;
    // End of variables declaration//GEN-END:variables

}
